/******************************init****************************/
function queryCommodityShow(page) {
	var parm = $('#queryCommodityShowForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('commodityshow-query');
	sys_record_parm('commodityshow',parm);
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#resultList').html(result);
		}
	});
}
function deleteCommodityShow(code) {
	$.Zebra_Dialog('是否删除',{
			'type': 'question',
			'title': '警告' ,
			'buttons':[
			           {caption:'删除',callback:function() {
			        		var url = create_url('commodityshow-delete');
							commodityRank_aidExecute(code, url);
			    		}},
			           {caption:'取消',callback:function(){}
			    	}]
			});
}
function commodityRank_aidExecute(code, url) {
	var parm = {'code':code};
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功');
				queryCommodityShow();
			} else {
				sys_msg('操作失败');
				queryCommodityShow();
			}
		}
	});
}
/************edit******************/
function saveCommodityShow() {
	var parm = $('#editCommodityShowForm').serialize();
	var url = create_url('commodityshow-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
		sys_submiting_close();
			if ('success' == result) {
				sys_msg('操作成功!');
				sys_load_handle('commodityshow');
			}
		}
	});
}

function selectCommodity() {
		var url = create_url('commodityshow-queryCommodityInit');
		var parm = {};
		$.colorbox({overlayClose:false, href:url, data:parm, close:'[关闭]', width:'750px',height:'500px', open:true});
}

function checkedCommodityShow(){
	var name = $("#name").val();
	var sort = $("#sort").val();
	if(name.length == 0){
		sys_msg('必须选择产品！');
		return
	}
	if(sort.length == 0){
		sys_msg('必须填写产品排行号!');
		return
	}else if(sort <= 0){
		sys_msg('排好序号必须是大于0的整数!');
		return
	}
	saveCommodityShow();
}

/******************************aidinit****************************/
function aid_queryCommodity(page) {
	var parm = $('#queryCommodityForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('commodityshow-queryCommodityList');
	sys_loading();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#resultList').html(result);
		}
	});
}

function aid_chooseWorkGuideOrgan(code, name,price) {
	$("#cc").val(code);
	$("#name").val(name);
	$("#price").val(price);
	$.fn.colorbox.close();
}


$(".txt_userlist_name").keydown(function(event) {
	if (event.keyCode == '13') {
		aid_queryCommodity();
		return false;
	}
});
/******************************aidbatchinit****************************/
